/*
 * ﻿Copyright (C) 2009-2013 NewMain Softech
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package com.newmainsoftech.gwetons.client.ui;

import com.google.gwt.event.dom.client.DomEvent;
import com.google.gwt.event.logical.shared.HasAttachHandlers;
import com.google.gwt.event.logical.shared.HasBeforeSelectionHandlers;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.DecoratedTabPanel;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IndexedPanel;
import com.google.gwt.user.client.ui.IsRenderable;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Interface defining common public methods between {@link TabLayoutPanel} and {@link DecoratedTabPanel}.
 * 
 * @author Arata Y.
 */
public interface TabPanelCase 
extends HasBeforeSelectionHandlers<Integer>, HasSelectionHandlers<Integer>, HasHandlers, EventListener, 
HasAttachHandlers, IsWidget, HasWidgets, IndexedPanel.ForIsWidget, Iterable<Widget>, IsRenderable
{
	public int getSelectedIndex();	
		// Although  DecoratedTabPanel does not have getSelectedIndex, defines here.
	
	// Methods from common interfaces between TabLayoutPanel class and DecoratedTabPanel class
// Defined in HasWidgets interface ----------------------------------------------------------------
//	public void add( Widget w);
//	public void clear();
//	public boolean remove( Widget widget);
// ------------------------------------------------------------------------------------------------
	public void add( IsWidget w, IsWidget tabWidget);
	public void add( IsWidget w, String tabText);
	public void add( IsWidget w, String tabText, boolean asHTML);
	public void add( Widget w, String text);
	public void add( Widget w, String text, boolean asHtml);
	public void add( Widget w, Widget tab);
// Defined in HasBeforeSelectionHandlers<Integer> interface ---------------------------------------
//	public HandlerRegistration addBeforeSelectionHandler( BeforeSelectionHandler<Integer> handler);
// ------------------------------------------------------------------------------------------------	
	/**
	* For <a href=
	* "http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks"
	* >browsers which do not leak</a>, adds a native event handler to the widget.
	* Note that, unlike the
	* {@link #addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)}
	* implementation, there is no need to attach the widget to the DOM in order
	* to cause the event handlers to be attached.
	*
	* @param <H> the type of handler to add
	* @param type the event key
	* @param handler the handler
	* @return {@link HandlerRegistration} used to remove the handler
	*/
	public <H extends EventHandler> HandlerRegistration addBitlessDomHandler(
			final H handler, DomEvent.Type<H> type);
  /**
   * Adds a native event handler to the widget and sinks the corresponding
   * native event. If you do not want to sink the native event, use the generic
   * addHandler method instead.
   *
   * @param <H> the type of handler to add
   * @param type the event key
   * @param handler the handler
   * @return {@link HandlerRegistration} used to remove the handler
   */
	public <H extends EventHandler> HandlerRegistration addDomHandler(
			final H handler, DomEvent.Type<H> type);
	/**
	* Adds this handler to the widget.
	*
	* @param <H> the type of handler to add
	* @param type the event type
	* @param handler the handler
	* @return {@link HandlerRegistration} used to remove the handler
	*/
	public <H extends EventHandler> HandlerRegistration addHandler(
			final H handler, GwtEvent.Type<H> type);	
// Defined in HasSelectionHandlers<Integer> interface ---------------------------------------------
//	public HandlerRegistration addSelectionHandler( SelectionHandler<Integer> handler);
//	public void fireEvent( GwtEvent<?> event);
// ------------------------------------------------------------------------------------------------	
//	public Widget getWidget( int index);
// 	Defined in IndexedPanel.ForIsWidget interface -------------------------------------------------
//	public int getWidgetIndex( Widget child);
//	public int getWidgetIndex( IsWidget child);
// ------------------------------------------------------------------------------------------------
	
	public void insert( IsWidget widget, IsWidget tabWidget, int beforeIndex);
	public void insert( IsWidget widget, String tabText, boolean asHTML, int beforeIndex);	
	public void insert( IsWidget widget, String tabText, int beforeIndex);
	public void insert( Widget widget, String tabText, boolean asHTML, int beforeIndex);
	public void insert( Widget widget, java.lang.String tabText, int beforeIndex);
	public void insert( Widget widget, Widget tabWidget, int beforeIndex);
// Defined in Iterable<Widget> interface ----------------------------------------------------------
//	public Iterator<Widget> iterator();
// ------------------------------------------------------------------------------------------------
//	public boolean remove( int index);
	public void selectTab( int index);
	public void selectTab(int index, boolean fireEvents);
	
	// non-static Methods from common super Composit class or higher 
	// between TabLayoutPanel class and DecoratedTabPanel class
	public boolean isAttached();
// Defined in EventListener interface -------------------------------------------------------------
//	public void onBrowserEvent( Event event);
// ------------------------------------------------------------------------------------------------
	
	public Object getLayoutData();
	public Widget getParent();
	public void removeFromParent();
	public void setLayoutData( Object layoutData);
	public void sinkEvents( int eventBitsToAdd);
	
	public void addStyleDependentName( String styleSuffix);
	public void addStyleName( String style);
	public void ensureDebugId( String id);
	public int getAbsoluteLeft();
	public int getAbsoluteTop();
	public Element getElement();
	public int getOffsetHeight();
	public int getOffsetWidth();
	public String getStyleName();
	public String getStylePrimaryName();
	public String getTitle();
	public boolean isVisible();
	public void removeStyleDependentName( String styleSuffix);
	public void removeStyleName( String style);
	public void setHeight( String height);
	public void setPixelSize( int width, int height);
	public void setSize( String width, String height);
	/**
	* Adds or removes a dependent style name by specifying the style name's
	* suffix. The actual form of the style name that is added is:
	* 
	* <pre class="code">
	* getStylePrimaryName() + '-' + styleSuffix
	* </pre>
	* 
	* @param styleSuffix the suffix of the dependent style to be added or removed
	* @param add <code>true</code> to add the given style, <code>false</code> to
	*          remove it
	* @see #addStyleDependentName(String)
	* @see #setStyleName(String, boolean)
	* @see #removeStyleDependentName(String)
	*/
	public void setStyleDependentName( String styleSuffix, boolean add);	
	public void setStyleName( String style);
	/**
	* Adds or removes a style name. This method is typically used to remove
	* secondary style names, but it can be used to remove primary stylenames as
	* well. That use is not recommended.
	* 
	* @param style the style name to be added or removed
	* @param add <code>true</code> to add the given style, <code>false</code> to
	*          remove it
	* @see #addStyleName(String)
	* @see #removeStyleName(String)
	*/
	public void setStyleName( String style, boolean add);	
	public void setStylePrimaryName( String style);
	public void setTitle( String title);
	public void setVisible( boolean visible);
	/**
	* Sinks a named event. Note that only {@link Widget widgets} may actually
	* receive events, but can receive events from all objects contained within
	* them.
	* 
	* @param eventTypeName name of the event to sink on this element
	* @see com.google.gwt.user.client.Event
	*/
	public void sinkBitlessEvent( String eventTypeName);	
	public void setWidth(java.lang.String width);
	public String toString();
	public void unsinkEvents( int eventBitsToRemove);
}
